package com.woniuxy.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseData<T> {
    private Integer code;
    private String msg;
    private T data;
    public ResponseData ok(){
        return new ResponseData(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMsg(),null);
    }
    public ResponseData ok(T data){
        return new ResponseData(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMsg(),data);
    }

    public ResponseData fail(ResponseEnum responseEnum){
        return new ResponseData(responseEnum.getCode(),responseEnum.getMsg(),null);
    }
    public ResponseData fail(ResponseEnum responseEnum,T data){
        return new ResponseData(responseEnum.getCode(), responseEnum.getMsg(), data);
    }

}
